package com.recruit.controller;

import com.recruit.common.FileUtil;
import io.github.talelin.core.annotation.Logger;
import io.github.talelin.core.annotation.LoginRequired;
import com.recruit.bo.FileBO;
import com.recruit.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import java.io.File;
import java.util.List;

@RestController
@RequestMapping("/recruit/file")
public class FileController {

    @Autowired
    private FileService fileService;

    @Value("${file.recruit}")
    private String recruit;

    @PostMapping
    public ResponseEntity<Object> upload(@RequestParam MultipartFile file) {

        File uploadFile = FileUtil.upload(file, recruit);
        assert uploadFile != null;

        return ResponseEntity.ok(uploadFile.getName());

    }
}
